package com.pay.task.job;

import com.pay.common.resp.Response;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * 定时任务,每隔一段时间获取 中间状态的数据,去查询结果
 */
@Component
public class TradePollingJob {


    @Autowired
    private RestTemplate restTemplate;

    String payChannel = "alipay";

    /**
     * 配置cron 表达式每隔5分钟查询数据调用支付渠道的接口支付查询结果
     */
//    @Scheduled(cron = "0 0/1 * * * ?")

    @XxlJob("tradePolling")
    public void excute(){

        System.out.println("----表达式每隔5分钟查询数据调用支付渠道的接口支付查询结果----------");

        //select * from tb_pay_serials WHERE pay_status in(1,2);


        //调用支付查询接口

        String url = "http://127.0.0.1:8084/trade/polling?payChannel=" + payChannel;
        Response response =  restTemplate.getForObject(url, Response.class);

        // 任务执行成功 任务是否执行成功
    }


}
